# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=tcpreplay
pkgver=4.5.1
pkgrel=0
pkgdesc="Replay captured network traffic"
url="https://tcpreplay.appneta.com/"
arch="all"
license="GPL-3.0-or-later"
makedepends="linux-headers libdnet-dev libpcap-dev tcpdump"
subpackages="$pkgname-doc"
source="https://downloads.sourceforge.net/tcpreplay/tcpreplay-$pkgver.tar.gz
	skip-tests-require-root.patch
	"

case "$CARCH" in
arm*)
	options="$options !check" # bus error
	;;
esac

# secfixes:
#   4.4.1-r0:
#     - CVE-2021-45386
#     - CVE-2021-45387
#   4.3.2-r0:
#     - CVE-2019-8381
#     - CVE-2019-8376
#     - CVE-2019-8377
#   4.3.4-r0:
#     - CVE-2020-24265
#     - CVE-2020-24266

prepare() {
	default_prepare
	update_config_sub
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--enable-dynamic-link \
		--enable-local-libopts \
		--disable-libopts-install
	make
}

check() {
	make -C test tcpprep
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
75d6bbdf469d4eab5c5206422ec1dcf8ccda1469b1cf36fa37d65550fc781f91919e315708f2cca6b25ac396a4c2395c67f653b6a11901b5568d450ae4424333  tcpreplay-4.5.1.tar.gz
cd8e1f7cd9a1fccf018e1bcbe0da86552e5adeecb679be15f2e492640af856eaf1b7266b5316674e3fe20c57d35d963292c18841db344eee4349b4a0d8496ded  skip-tests-require-root.patch
"
